<?php

namespace App\Http\Controllers;

use App\Models\Message;
use App\Transformers\MessageTransformer;
use Illuminate\Http\Request;

class MessageController extends ApiController
{
    public function more()
    {
        $message = Message::where('to_user_id',$this->user->id)->orderByDesc('id')->paginate(10);
        $messages = (new MessageTransformer())->listData($message->getCollection());
        
        return $this->setPage($message->hasMorePages())->success($messages);
    }
}
